home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / libx11inc.lha / X11 / Xm / TextFP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-13  |  14.6 KB  |  356 lines

  1. /* 
  2.  * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
  3.  * ALL RIGHTS RESERVED
  4. */ 
  5. /*   $RCSfile: TextFP.h,v $ $Revision: 1.43 $ $Date: 92/05/14 12:58:45 $ */
  6. /*
  7. *  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 HEWLETT-PACKARD COMPANY */
  8. #ifndef _XmTextFP_h
  9. #define _XmTextFP_h
  10.  
  11. #include <Xm/PrimitiveP.h>
  12. #include <Xm/TextF.h>
  13.  
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17.  
  18. /*
  19.  * Defines for different cursors
  20.  */
  21.  
  22. #define IBEAM_WIDTH 3
  23. #define CARET_WIDTH 9
  24. #define CARET_HEIGHT 5
  25.  
  26. #ifdef NOT_DEF
  27. static unsigned char caretBits[] = {
  28.    0x10, 0x00, 0x38, 0x00, 0x6c, 0x00, 0xc6, 0x00, 0x83, 0x01};
  29. #endif /* NOT_DEF */
  30.  
  31. /*
  32.  * Here is the Text Field Widget class structure.
  33.  */
  34.  
  35. typedef struct _XmTextFieldClassPart
  36.   {
  37.     XtPointer extension;        /* Pointer to extension record. */
  38.   }
  39.   XmTextFieldClassPart;
  40.  
  41. typedef struct _XmTextFieldClassRec
  42.   {
  43.     CoreClassPart core_class;  /* Not RectObjClassPart so I can reference
  44.                   core_class s */
  45.     XmPrimitiveClassPart primitive_class;
  46.     XmTextFieldClassPart text_class;
  47.   }
  48.   XmTextFieldClassRec;
  49.  
  50. externalref XmTextFieldClassRec xmTextFieldClassRec;
  51.  
  52. /*
  53.  * Here is the Text Field Widget instance structures.
  54.  */
  55.  
  56. typedef struct _XmTextFieldPart
  57.   {
  58.     XtCallbackList activate_callback;       /* Command activate callback */
  59.     XtCallbackList focus_callback;  /* Verify losing focus callback */
  60.     XtCallbackList losing_focus_callback;  /* Verify losing focus callback */
  61.     XtCallbackList modify_verify_callback; /* Verify value to change callback */
  62.     XtCallbackList wcs_modify_verify_callback; /* Verify value to change 
  63.                         * callback */
  64.     XtCallbackList motion_verify_callback; /* Verify insert cursor position to
  65.                           change callback */
  66.     XtCallbackList gain_primary_callback; /* Gained ownership of Primary
  67.                                              Selection */
  68.     XtCallbackList lose_primary_callback; /* Lost ownership of Primary
  69.                                              Selection */
  70.     XtCallbackList value_changed_callback; /* Notify that value has change                              callback */
  71.     char * value;        /* pointer to widget value stored as char* */
  72.     wchar_t * wc_value;        /* pointer to widget value stored as wchar_t* */
  73.  
  74.     XmFontList font_list;    /* Uses only the font portion of fontlist */
  75.     XFontStruct *font;            /* font retrieved from the fontlist */
  76.     XmTextScanType *selection_array; /* Description of what to cycle
  77.                          through on selections */
  78.     _XmHighlightData highlight;    /* Info on the highlighting regions. */
  79.  
  80.     GC gc;            /* Normal GC for drawing text and cursor */
  81.     GC image_gc;        /* Image GC for drawing text cursor*/
  82.     GC save_gc;                 /* GC for saving/restoring under IBeam */
  83.  
  84.     Pixmap ibeam_off;        /* pixmap for area under the IBeam */
  85.     Pixmap add_mode_cursor;    /* The add mode cursor pixmap */
  86.     Pixmap cursor;        /* The ibeam cursor stencil */
  87.     Pixmap putback;        /* AVAILABLE: was in 1.1 but not really used */
  88.     Pixmap stipple_tile;    /* The tile pattern for the stippled I-beam */
  89.     Pixmap image_clip;        /* The clip rect needed for image gc */
  90.  
  91.     XmTextPosition cursor_position;/* Character location of the insert cursor */
  92.     XmTextPosition new_h_offset;/* Used in setvaluesalmost proc */
  93.     XmTextPosition h_offset;      /* The x position of the first character
  94.                                    (relative to left edge of the widget) */
  95.     XmTextPosition orig_left;     /* Left primary selection prior to extend */
  96.     XmTextPosition orig_right;    /* Right primary selection prior to extend */
  97.     XmTextPosition prim_pos_left; /* Left primary selection position */
  98.     XmTextPosition prim_pos_right; /* Right primary selection position */
  99.     XmTextPosition prim_anchor;    /* Primary selection pivot point */
  100.  
  101.     XmTextPosition sec_pos_left; /* Left secondary selection position */
  102.     XmTextPosition sec_pos_right; /* Right secondary selection position */
  103.     XmTextPosition sec_anchor;    /* Secondary selection pivot point */
  104.  
  105.     XmTextPosition stuff_pos;    /* Position to stuff the primary selection */
  106.  
  107.     Position select_pos_x;    /* x position for timer-based scrolling */
  108.  
  109.     Time prim_time;             /* Timestamp of primary selection */
  110.     Time dest_time;             /* Timestamp of destination selection */
  111.     Time sec_time;              /* Timestamp of secondary selection */
  112.     Time last_time;             /* Time of last selection event */
  113.  
  114.     XtIntervalId timer_id;    /* Blinking cursor timer */
  115.     XtIntervalId select_id;     /* Timer based scrolling identifier */
  116.  
  117.     int blink_rate;        /* Rate of blinking text cursor in msec */
  118.     int selection_array_count;  /* Selection array count */
  119.     int threshold;        /* Selection threshold */
  120.     int size_allocd;        /* Size allocated for value string */
  121.     int string_length;          /* The number of characters in the string 
  122.                    (including the trailing NULL) */
  123.     int cursor_height;        /* Save cursor dimensions */
  124.     int cursor_width;        /* Save cursor dimensions */
  125.     int sarray_index;        /* Index into selection array */
  126.     int max_length;        /* Maximum number of character that can be
  127.                    inserted into the text field widget */
  128.  
  129.     int max_char_size;          /* Max bytes per character in cur locale */
  130.     short columns;        /* The number of characters in the width */
  131.  
  132.     Dimension margin_width;    /* Height between text borders and text */
  133.     Dimension margin_height;    /* Width between text borders and text */
  134.     Dimension average_char_width;/* Average character width based on font */
  135.     Dimension margin_top;   /* Height between text borders and top of text */
  136.     Dimension margin_bottom;/* Height between text borders and bottom of text */
  137.     Dimension font_ascent;  /* Ascent of font or fontset used by widget */
  138.     Dimension font_descent;  /* Descent of font or fontset used by widget */
  139.  
  140.     Boolean resize_width;    /* Allows the widget to grow horizontally
  141.                    when borders are reached */
  142.     Boolean pending_delete;    /* Delete primary selection on insert when
  143.                    set to True */
  144.     Boolean editable;        /* Sets editablility of text */
  145.     Boolean verify_bell;          /* Determines if bell is sounded when verify
  146.                                    *  callback returns doit - False
  147.                                    */
  148.     Boolean cursor_position_visible;    /* Sets visibility of insert cursor */
  149.  
  150.     Boolean traversed;          /* Flag used with losing focus verification to
  151.                                    indicate a traversal key pressed event */
  152.     Boolean add_mode;        /* Add mode for cursor movement */
  153.     Boolean has_focus;        /* Flag that indicates whether the widget
  154.                        has input focus */
  155.     Boolean blink_on;        /* State of Blinking insert cursor */
  156.     short int cursor_on;    /* Indicates whether the cursor is visible */
  157.     Boolean refresh_ibeam_off;    /* Indicates whether the area under IBeam needs
  158.                    to be re-captured */
  159.     Boolean have_inverted_image_gc;  /* fg/bg of image gc have been swapped */
  160.     Boolean has_primary;    /* Indicates that is has the
  161.                    primary selection */
  162.     Boolean has_secondary;    /* Indicates that is has the
  163.                    secondary selection */
  164.     Boolean has_destination;    /* Indicates that is has the
  165.                    destination selection */
  166.     Boolean sec_drag;           /* Indicates a secondary drag was made */ 
  167.     Boolean selection_move;    /* Indicates that the action requires a
  168.                    secondary move (i.e. copy & cut) */
  169.     Boolean pending_off;    /* indicates pending delete state */
  170.     Boolean fontlist_created;   /* Indicates that the text field widget created
  171.                    it's own fontlist */
  172.     Boolean has_rect;        /* currently has clipping rectangle */
  173.     Boolean do_drop;        /* Indicates that the widget the recieved the
  174.                    button release, did not have a previous
  175.                                    button press, so it is o.k. to request
  176.                    the MOTIF_DROP selection. */
  177.     Boolean cancel;        /* Cancels selection actions when true */
  178.     Boolean extending;        /* Indicates extending primary selection */
  179.     Boolean sec_extending;      /* Indicates extending secondary selection */
  180.     Boolean changed_visible;    /* Indicates whether the dest_visible flag
  181.                                    is in a temporary changed state */
  182.     Boolean have_fontset;       /* The widgets font is a fontset, not a 
  183.                  * fontstruct... use R5 draw routines */
  184.     Boolean in_setvalues;    /* used to disable unnecessary redisplays */
  185.     Boolean do_resize;        /* used to prevent inappropriate resizes */
  186.     Boolean redisplay;        /* used to set redisplay flag in setvalues */
  187.     Boolean overstrike;        /* overstrike mode for character input */
  188.     Boolean sel_start;        /* overstrike mode for character input */
  189.     XtPointer extension;    /* Pointer to extension record. */
  190.   }
  191.   XmTextFieldPart;
  192.  
  193. typedef struct _XmTextFieldRec
  194.   {
  195.     CorePart core;
  196.     XmPrimitivePart primitive;
  197.     XmTextFieldPart text;
  198.   }
  199.   XmTextFieldRec;
  200.  
  201. /****************
  202.  *
  203.  * Macros for the uncached data
  204.  *
  205.  ****************/
  206.  
  207. #define TextF_ActivateCallback(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  208.                        text.activate_callback)
  209. #define TextF_LosingFocusCallback(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  210.                        text.losing_focus_callback)
  211. #define TextF_FocusCallback(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  212.                        text.focus_callback)
  213. #define TextF_ModifyVerifyCallback(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  214.                        text.modify_verify_callback)
  215. #define TextF_ModifyVerifyCallbackWcs(tfg)      (((XmTextFieldWidget)(tfg)) -> \
  216.                        text.wcs_modify_verify_callback)
  217. #define TextF_MotionVerifyCallback(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  218.                        text.motion_verify_callback)
  219. #define TextF_ValueChangedCallback(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  220.                        text.value_changed_callback)
  221. #define TextF_Value(tfg)                        (((XmTextFieldWidget)(tfg)) -> \
  222.                        text.value)
  223. #define TextF_WcValue(tfg)                      (((XmTextFieldWidget)(tfg)) -> \
  224.                        text.wc_value)
  225. #define TextF_MarginHeight(tfg)                (((XmTextFieldWidget)(tfg)) -> \
  226.                        text.margin_height)
  227. #define TextF_MarginWidth(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  228.                        text.margin_width)
  229. #define TextF_CursorPosition(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  230.                        text.cursor_position)
  231. #define TextF_Columns(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  232.                        text.columns)
  233. #define TextF_MaxLength(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  234.                        text.max_length)
  235. #define TextF_BlinkRate(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  236.                        text.blink_rate)
  237. #define TextF_FontList(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  238.                        text.font_list)
  239. #define TextF_Font(tfg)                (((XmTextFieldWidget)(tfg)) -> \
  240.                        text.font)
  241. #define TextF_FontAscent(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  242.                        text.font_ascent)
  243. #define TextF_FontDescent(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  244.                        text.font_descent)
  245. #define TextF_SelectionArray(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  246.                        text.selection_array)
  247. #define TextF_SelectionArrayCount(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  248.                        text.selection_array_count)
  249. #define TextF_ResizeWidth(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  250.                        text.resize_width)
  251. #define TextF_PendingDelete(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  252.                        text.pending_delete)
  253. #define TextF_Editable(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  254.                        text.editable)
  255. #define TextF_CursorPositionVisible(tfg)    (((XmTextFieldWidget)(tfg)) -> \
  256.                        text.cursor_position_visible)
  257. #define TextF_Threshold(tfg)               (((XmTextFieldWidget)(tfg)) -> \
  258.                        text.threshold)
  259. #define TextF_UseFontSet(tfg)               (((XmTextFieldWidget)(tfg)) -> \
  260.                        text.have_fontset)
  261.  
  262. /********    Private Function Declarations    ********/
  263. #ifdef _NO_PROTO
  264.  
  265. extern int _XmTextFieldCountBytes() ;
  266. extern Widget _XmTextFieldGetDropReciever() ;
  267. extern void _XmTextFToggleCursorGC() ;
  268. extern void _XmTextFieldDrawInsertionPoint() ;
  269. extern void _XmTextFieldSetClipRect() ;
  270. extern void _XmTextFieldSetCursorPosition() ;
  271. extern Boolean _XmTextFieldReplaceText() ;
  272. extern void _XmTextFieldDeselectSelection() ;
  273. extern Boolean _XmTextFieldSetDestination() ;
  274. extern void _XmTextFieldStartSelection() ;
  275. extern void _XmTextFieldSetSel2() ;
  276.  
  277. #else
  278.  
  279. extern int _XmTextFieldCountBytes( 
  280.                         XmTextFieldWidget tf,
  281.                         wchar_t *wc_value,
  282.                         int num_chars) ;
  283. extern Widget _XmTextFieldGetDropReciever( 
  284.                         Widget w) ;
  285. extern void _XmTextFToggleCursorGC( 
  286.                         Widget widget) ;
  287. extern void _XmTextFieldDrawInsertionPoint( 
  288.                         XmTextFieldWidget tf,
  289. #if NeedWidePrototypes
  290.                         int turn_on) ;
  291. #else
  292.                         Boolean turn_on) ;
  293. #endif /* NeedWidePrototypes */
  294. extern void _XmTextFieldSetClipRect( 
  295.                         XmTextFieldWidget tf) ;
  296. extern void _XmTextFieldSetCursorPosition( 
  297.                         XmTextFieldWidget tf,
  298.                         XEvent *event,
  299.                         XmTextPosition position,
  300. #if NeedWidePrototypes
  301.                         int adjust_flag,
  302.                         int call_cb) ;
  303. #else
  304.                         Boolean adjust_flag,
  305.                         Boolean call_cb) ;
  306. #endif /* NeedWidePrototypes */
  307. extern Boolean _XmTextFieldReplaceText( 
  308.                         XmTextFieldWidget tf,
  309.                         XEvent *event,
  310.                         XmTextPosition replace_prev,
  311.                         XmTextPosition replace_next,
  312.                         char *insert,
  313.                         int insert_length,
  314. #if NeedWidePrototypes
  315.                         int move_cursor) ;
  316. #else
  317.                         Boolean move_cursor) ;
  318. #endif /* NeedWidePrototypes */
  319. extern void _XmTextFieldDeselectSelection( 
  320.                         Widget w,
  321. #if NeedWidePrototypes
  322.                         int disown,
  323. #else
  324.                         Boolean disown,
  325. #endif /* NeedWidePrototypes */
  326.                         Time sel_time) ;
  327. extern Boolean _XmTextFieldSetDestination( 
  328.                         Widget w,
  329.                         XmTextPosition position,
  330.                         Time set_time) ;
  331. extern void _XmTextFieldStartSelection( 
  332.                         XmTextFieldWidget tf,
  333.                         XmTextPosition left,
  334.                         XmTextPosition right,
  335.                         Time sel_time) ;
  336. extern void _XmTextFieldSetSel2( 
  337.                         Widget w,
  338.                         XmTextPosition left,
  339.                         XmTextPosition right,
  340. #if NeedWidePrototypes
  341.                         int disown,
  342. #else
  343.                         Boolean disown,
  344. #endif /* NeedWidePrototypes */
  345.                         Time sel_time) ;
  346.  
  347. #endif /* _NO_PROTO */
  348. /********    End Private Function Declarations    ********/
  349.  
  350.  
  351. #ifdef __cplusplus
  352. }  /* Close scope of 'extern "C"' declaration which encloses file. */
  353. #endif
  354.  
  355. #endif /* _XmTextFieldWidgetP_h */
  356.